package operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class DeleteOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println();
        System.out.println("*************************");
        Scanner scanner=new Scanner(System.in);

        System.out.println("请输入需要删除的书籍名称：");
        String name=scanner.nextLine();

        int bnum=bookList.getNum();

        for (int i = 0; i < bnum; i++) {
            Book book=bookList.getBooks(i);
            if (book.getName().equals(name)){
                bookList.deleteBooks(i);
                System.out.println("删除成功！");
                System.out.println();
                System.out.println("*************************");
                return;
            }

        }
        System.out.println("未找到你要删除的书籍！");
        System.out.println();
        System.out.println("*************************");

    }
}
